

#ifndef UC_GEINTRVL_H
#define UC_GEINTRVL_H

#include "zgegbl.h"
#pragma pack (push, 8)
class UcGeImpInterval;
class
GE_DLLEXPIMPORT
UcGeInterval
{
public:
    UcGeInterval(double tol = 1.e-12);
    UcGeInterval(const UcGeInterval& src);
    UcGeInterval(double lower, double upper, double tol = 1.e-12);
    UcGeInterval(ZSoft::Boolean boundedBelow, double bound,
                 double tol = 1.e-12);
    ~UcGeInterval();

    UcGeInterval&  operator =       (const UcGeInterval& otherInterval);

    double         lowerBound       () const;
    double         upperBound       () const;
    double         element          () const;
    void           getBounds        (double& lower, double& upper) const;
    double         length           () const;
    double         tolerance        () const;

    UcGeInterval&  set              (double lower, double upper);
    UcGeInterval&  set              (ZSoft::Boolean boundedBelow, double bound);
    UcGeInterval&  set              ();
    UcGeInterval&  setUpper         (double upper);
    UcGeInterval&  setLower         (double lower);
    UcGeInterval&  setTolerance     (double tol);

    void           getMerge         (const UcGeInterval& otherInterval, UcGeInterval& result) const;
    int            subtract         (const UcGeInterval& otherInterval,
                                     UcGeInterval& lInterval,
                                     UcGeInterval& rInterval) const;
    ZSoft::Boolean intersectWith    (const UcGeInterval& otherInterval, UcGeInterval& result) const;

    ZSoft::Boolean isBounded        () const;
    ZSoft::Boolean isBoundedAbove   () const;
    ZSoft::Boolean isBoundedBelow   () const;
    ZSoft::Boolean isUnBounded      () const;
    ZSoft::Boolean isSingleton      () const;

    ZSoft::Boolean isDisjoint       (const UcGeInterval& otherInterval) const;
    ZSoft::Boolean contains         (const UcGeInterval& otherInterval) const;
    ZSoft::Boolean contains         (double val) const;

    ZSoft::Boolean isContinuousAtUpper (const UcGeInterval& otherInterval) const;
    ZSoft::Boolean isOverlapAtUpper    (const UcGeInterval& otherInterval,
                                        UcGeInterval& overlap) const;

    ZSoft::Boolean operator ==      (const UcGeInterval& otherInterval) const;
    ZSoft::Boolean operator !=      (const UcGeInterval& otherInterval) const;
    ZSoft::Boolean isEqualAtUpper   (const UcGeInterval& otherInterval) const;
    ZSoft::Boolean isEqualAtUpper   (double value) const;
    ZSoft::Boolean isEqualAtLower   (const UcGeInterval& otherInterval) const;
    ZSoft::Boolean isEqualAtLower   (double value) const;

    ZSoft::Boolean isPeriodicallyOn (double period, double& val);

    friend
    GE_DLLEXPIMPORT
    ZSoft::Boolean operator >       (double val, const UcGeInterval& intrvl);
    ZSoft::Boolean operator >       (double val) const;
    ZSoft::Boolean operator >       (const UcGeInterval& otherInterval) const;
    friend
    GE_DLLEXPIMPORT
    ZSoft::Boolean operator >=      (double val, const UcGeInterval& intrvl);
    ZSoft::Boolean operator >=      (double val) const;
    ZSoft::Boolean operator >=      (const UcGeInterval& otherInterval) const;
    friend
    GE_DLLEXPIMPORT
    ZSoft::Boolean operator <       (double val, const UcGeInterval& intrvl);
    ZSoft::Boolean operator <       (double val) const;
    ZSoft::Boolean operator <       (const UcGeInterval& otherInterval) const;
    friend
    GE_DLLEXPIMPORT
    ZSoft::Boolean operator <=      (double val, const UcGeInterval& intrvl);
    ZSoft::Boolean operator <=      (double val) const;
    ZSoft::Boolean operator <=      (const UcGeInterval& otherInterval) const;

protected:
    friend class UcGeImpInterval;

    UcGeImpInterval  *mpImpInt;

    UcGeInterval (UcGeImpInterval&, int);

private:
    int              mDelInt;
};

#pragma pack (pop)
#endif
